@extends('layouts.app')

@section('title', 'Append Record')

@section('css')
    <link href="{{url('/css/redactor.css')}}" rel="stylesheet">
@endsection

@section('content')
    <div class="container">
        <div class="col-lg-8 col-lg-offset-2" style="margin-top: 80px">
            @if (session('success'))
                <div class="alert alert-dismissible alert-success">
                    <button type="button" class="close" data-dismiss="alert">&times;</button>
                    <strong>Success</strong> {{session('success')}}
                </div>
            @endif
            @if (session('error'))
                <div class="alert alert-dismissible alert-danger">
                    <button type="button" class="close" data-dismiss="alert">&times;</button>
                    <strong>Error</strong> {{session('error')}}
                </div>
            @endif
            @if (!empty($child))
            <form class="form-horizontal" action="{{url('/record/child/edit')}}" method="post">
                <div class="h4">
                    <span class="glyphicon glyphicon-cog">Edit Record Child</span>
                    <hr style="margin-top: 8px">
                </div>
                {{csrf_field()}}
                <input type="hidden" name="id" value="{{$child->id}}">
                <div class="form-group @if($errors->has('title')) has-error @endif">
                    <div class="col-lg-12">
                        <label for="title" class="">Title</label>
                        <input class="form-control" id="title" name="title"
                               value="{{$child->title or ''}}">
                        @if($errors->has('title'))<span
                                class="help-block"><strong>{{ $errors->first('title') }}</strong></span> @endif
                    </div>
                </div>

                <div class="form-group @if($errors->has('description')) has-error @endif">
                    <div class="col-lg-12">
                        <label for="description" class="">Description</label>
                        <textarea class="form-control" rows="3" id="description" name="description"
                                  style="max-width: 100%;min-width: 100%">{{$child->description or ''}}</textarea>
                        @if($errors->has('description'))
                            <span class="help-block"><strong>{{ $errors->first('description') }}</strong></span>
                        @endif
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-lg-12">
                        <button type="submit" class="btn btn-success btn-block">Submit</button>
                    </div>
                </div>
            </form>
            @else
                <h2 class="text-center">数据不存在</h2>
            @endif
        </div>
    </div>
@endsection

@section('js')
    <script src="{{url('/js/redactor.js')}}"></script>
    <script>
        $(document).ready(function () {
            $('textarea').redactor({
                lang: 'zh_cn',
                minHeight: 300,
                imageUpload: '/upload/img',
                plugins: ['fontcolor', 'fontsize', 'fullscreen', 'source', 'inlinestyle']
            });
        });

    </script>
@endsection